package com.googlecode.cswish.struts;

import ognl.NullHandler;

import com.googlecode.cswish.struts.conversion.DefaultObjectTypeDeterminer;
import com.googlecode.cswish.struts.spring.StrutsObjectFactory;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.inject.Scope;
import com.opensymphony.xwork2.util.location.LocatableProperties;

/**
 * Register cswish extension to container
 * 
 * @author feng Date: 2009-4-3
 */
public class CSwishConfigurationProvider implements ConfigurationProvider {

    public void destroy() {
    }

    public void init(Configuration configuration) throws ConfigurationException {
    }

    public void loadPackages() throws ConfigurationException {
    }

    public boolean needsReload() {
        return false;
    }

    public void register(ContainerBuilder builder, LocatableProperties props)
            throws ConfigurationException {
    	builder.factory(com.opensymphony.xwork2.ObjectFactory.class, StrutsObjectFactory.class, Scope.SINGLETON)
        	.factory(NullHandler.class, InstantiatingNullHandler.class, Scope.SINGLETON)
        	.factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON);
    }
}
